The technology described herein relates to graphics processing and in particular to the operation of graphics processing systems that include a fragment shading stage that generates interpolated vertex attribute data.
Graphics processing is typically carried out in a pipelined fashion, with one or more pipeline stages operating on the data to generate the final image that is displayed. Two important parts of this process typically are so-called vertex shading operations such as transformations and lighting that are carried out on the vertices of primitives (polygons) representing the image to be displayed, and the subsequent fragment (pixel) shading operations that shade (colour) the individual fragments that make up the image to be displayed.
The vertex shading operations are typically carried out in a so-called “vertex shader” stage of the graphics process. This is typically a programmable processing unit that executes vertex shader programs on input data values to generate a desired set of output data (e.g. appropriately transformed and lit vertex data) for processing by the rest of the graphics pipeline. Each primitive (polygon) of a scene is usually defined and represented as a set of vertices, with each vertex having associated with it a set of data values for the vertex. The vertex shading process modifies the initially defined data values for a vertex, e.g. based on any transformations or lighting that the primitive that the vertex relates to is to be subjected to.
Once the input data values for a scene have been vertex “shaded”, the primitives representing the scene are then usually rasterised to generate a plurality of “fragments” to be processed for the scene. Fragments are the discrete graphical entities on which the graphics processing operations (such as rendering) are carried out. Each fragment will correspond to a sampling point or sampling points of the scene and, once sampled, will have associated with it the necessary data, such as red, green, blue colour (RGB) values, a transparency (alpha) value, and a depth (z) value, to allow the sample point(s) to be displayed. Fragments may also be referred to as pixels, although it is not inevitably the case that a given fragment will correspond exactly to a single pixel (pixel element) in the final display, as post-processing, such as down-scaling, may mean that there is not a one-to-one correspondence between the entities (fragments) that the graphics processing operates on and the display pixels.
The graphics fragments, once generated, undergo a number of processes to shade them to generate their final output colour, etc., values, such as interpolation of vertex data, applying textures, blending, etc. Such processes to derive the output data values, etc., e.g. necessary to display the sample point(s) that the fragments represent, may be referred to as “fragment shading” or “pixel shading” and are carried out in a fragment shader (also called a pixel shader) stage of the processing pipeline. The fragment shading process processes the initially defined fragment data values for a fragment to derive the output data for the fragment (data needed to display the sample point(s) that the fragment represents) correctly. The fragment shader again may be a programmable unit that executes one or more fragment shader programs to shade (colour) the fragments appropriately. Fragments may be processed (e.g. sampled, shaded, etc.) individually or together in groups. For example, groups of 2×2 fragments are often processed together as a “quad”, although smaller or larger groups of fragments are sometimes used.
The vertex and fragment shading operations normally operate on so-called “attributes”. An attribute is an input or output variable in a shader program and may represent for example, a colour, transparency, texture coordinate, etc. The vertex shader will generate for each vertex used to define and represent each primitive (polygon) of a scene a set of attributes (colour, transparency, texture coordinates, etc.). These generated attributes may be referred to generally as vertex shaded attribute data.
As part of the fragment shading process, the fragment shader usually interpolates vertex shaded attribute data so as to generate interpolated attribute data for a fragment's sampling point(s). This process of providing the interpolated attribute data may be referred to generally as a varying calculation and may, for example, be carried out in a varying pipeline of the fragment shader. The varying pipeline usually includes a varying interpolator that inputs the vertex shaded attribute data and x,y coordinates for the fragment (e.g. for the fragment's sampling point(s)) and outputs the interpolated attribute data.
FIG. 1 illustrates an approach to interpolating vertex shaded attribute data in which a triangular primitive 5 is being sampled using a “quad” 10 of four fragments 6,7,8,9, with each of the fragments 6,7,8,9 having a central sample point. In this example, the x,y coordinates for each of the sampling points are directly used by a varying interpolator to evaluate a varying plane equation for the primitive so as to provide interpolated attribute data (S0, S1, S2, S3) for those sampling points. However, evaluating the varying plane equation for each set of x,y coordinates directly in this way can be computationally expensive.
FIG. 2 illustrates an alternative approach in which the x,y coordinates of just one of the sampling points of one of the fragments 6 are used directly to provide interpolated attribute data S0 for that sampling point. Sampling point delta values Sx, Sy are then used to provide interpolated attribute data S1, S2, S3 for each of the other sampling points of the other fragments 7,8,9, for example in the following manner:S1=S0+Sx S2=S0+Sy S3=S0+Sx+Sy 
Using sampling point delta values in this way can be computationally less expensive than using the x,y coordinates for each of the sampling points directly since it is not necessary to fully evaluate the varying plane equation for the primitive at each of the sampling points using the x,y coordinates of that sampling point. However, this approach can still be inefficient since the number of add operations that involve the sampling point delta values is not consistent across all of the sampling points. In particular, there is only a single add operation to generate S1 and S2, but two add operations to generate S3. This can mean, for example, that some adders which are used to perform the add operations may be left idle during some cycles of operation or a feedback loop may need to be included.
The Applicants believe that there remains scope for improvements to the operation of graphics processors that include a fragment shading stage that generates interpolated vertex attribute data.
Like reference numerals are used for like components where appropriate in the drawings.